package com.rabbit.mq;

import com.rabbit.config.MqConsumerConfig;
import com.rabbit.entity.Notice;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * @author yuhuan
 * @date 2025/4/21
 */
@Service
public class NoticeConsumer {

    /**
     * 从配置中获取队列名称{@link MqConsumerConfig#hotelQueue()} ()}
     */
    @RabbitListener(queues = "#{hotelQueue.name}", errorHandler = "unifiedExceptionHandler")
    public void receiveHotelNotice(Notice notice) {
        System.out.println(String.format("酒店接收到通知[%s]，正在处理：%s", notice.getCode(), notice));
    }

    @RabbitListener(queues = "#{adminQueue.name}", errorHandler = "unifiedExceptionHandler")
    public void receiveAdminNotice(Notice notice) {
        System.out.println(String.format("管理员接收到通知[%s]，正在处理：%s", notice.getCode(), notice));
    }
}
